package com.etop.weibo.beans;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

/**<p></p>
 * @author jansing
 */
@Entity
@Table(name = "t_user")
public class User {

    private int id;
    private String username;
    private String password;
    private String nickname;
    private String sex;
    private String introduction;

    public User() {
    }

    public User(String username, String password) {
        super();
        this.username = username;
        this.password = password;
    }

    public User(String username, String password, String nickname, String sex, String introduction) {
        this.username = username;
        this.password = password;
        this.nickname = nickname;
        this.sex = sex;
        this.introduction = introduction;
    }

    public User(int id, String username, String password, String nickname, String sex, String introduction) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.nickname = nickname;
        this.sex = sex;
        this.introduction = introduction;
    }

    @Id
    @GeneratedValue
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "username", nullable=false,unique=true )
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Column(name = "password")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "nickname")
    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Column(name = "sex")
    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
    @Column(name = "introduction")
    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    @Override
    public boolean equals(Object o) {
        return ((User) o).getId() == id;
    }
    
    @Override
    public String toString(){
        return this.username + " - " + this.nickname;
    }
}
